Part Number Hot Search : 
HS420 2951A A2010 6627US PCA4625 OB25FL24 COM200 28203
Product Description
Full Text Search
 

To Download AN2776 Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  may 2008 rev 1 1/20 AN2776 application note how to migrate from stm32f10xxx fwlib v1.0 to v2.0 introduction the purpose of this application note is to explain how to migrate an application based on the stm32f10xxx firmware library (fwlib) v1.0 to stm32f10xxx fwlib v2.0. to that aim, this document does not provide detailed information on the two library versions, but it highlights the differences between them. in the rest of the document (unless otherwise specified), th e term of fwlib will be used to refer to the stm32f10 xxx firmware library. glossary medium-density devices are stm32f101xx and stm32f103xx microcontrollers where the flash memory density ranges between 32 and 128 kbytes. high-density devices are stm32f101xx and stm32f103xx microcontrollers where the flash memory density ranges between 256 and 512 kbytes. www.st.com
contents AN2776 2/20 contents 1 why migrate from fwlib v1.0 to v2.0? . . . . . . . . . . . . . . . . . . . . . . . . . 4 2 fwlib v1.0 to v2.0 migration steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1 migration steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2 peripheral driver updates . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2.1 nvic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 2.2.2 tim . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 2.2.3 spi . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11 2.2.4 dma . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 2.2.5 usart . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 appendix a timer driver changes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
AN2776 list of tables 3/20 list of tables table 1. update of dma irq channel names . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 table 2. adc1 and adc2 irq channel name update . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8 table 3. common functions for spi and i 2 s . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12 table 4. changes made in the timer driver. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 table 5. document revision history . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
why migrate from fwlib v1.0 to v2.0? AN2776 4/20 1 why migrate from fwlib v1.0 to v2.0? fwlib v1.0 is a complete fi rmware package for medium-den sity stm32f10xxx devices. it is a collection of routines, data structures and macros, which covers the features of all peripherals. it includes drivers plus a set of examples for all of the standard device peripherals. fwlib v2.0 is an updated version of fwlib v1.0 that supports medium-density devices and the additional peripherals and features em bedded in high-densit y stm32f10xxx devices: embedded memories ? sram: up to 64 kb (instead of 20 kb in medium-density devices) ? flash: up to 512 kb (instead of 128 kb in medium-density devices) new peripherals ?sdio ? i2s2 and i2s3 (multiplexed with spi2 and spi3) ?dac ?fsmc new peripheral instantiation ? dma2 controller supporting 5 channels ? adc3 ?spi3 ? uart4 and uart5 do not support hardware flow control, smartcard mode (iso 7816 compliant) and spi-like communication ? tim8 (advanced-control timer) ? tim5 (general-purpose timer) ? tim6 and tim7 (basic timers that can be used to trigger the dac) miscellaneous changes ? backup user data extended from 20 bytes to 84 bytes ? up to 112 i/os: port f and g added (16 pins each) ? lsi calibration: lsi clock connected to the tim5_ch4 input capture for calibration purposes ? 112 exti line inputs instead of 80 ? 17 interrupt sources added (total of 60 interrupts) ? external/internal adc triggers the main differences between fwlib v1.0 and fwlib v2.0 are listed below: 1. update of library core files ( stm32f10x_map.h , stm32f10x_lib.h , stm32f10x_lib.c and stm32f10x_conf.h ) to add new peripheral register declarations and header file inclusions 2. update of stm32f10x_vector.s (or stm32f10x_vector.c , depending on the used toolchain) and stm32f10x_it.c / stm32f10x_it.h : device vector table updated with new peripheral irq channels 3. drivers added for new peripherals (like stm32f10x_fsmc.c/stm32f10x_fsmc.h )
AN2776 why migrate from fwlib v1.0 to v2.0? 5/20 4. update of existing drivers to support the added peripheral instantiation and miscellaneous additional changes. on this occasion, the apis (application programming interfaces) of some drivers were changed, leading to loss of compatibility with fwlib v1.0. this applies to the drivers of the following peripherals: tim, spi, dma, usart and nvic. note: 1 loss of compatibility mean s that an application code ba sed on one of the above listed fwlib v1.0 peripheral drivers needs updating to work correctly with fwlib v2.0. 2 fwlib v2.0 comes with eighty-seven (87) examples that cover a wide range of the peripheral functionalities. if fwlib v1.0 is used in an application based on medium-density stm32f10xxx devices and migration to high-density stm32f10xxx devices is contemplated, two cases should be considered: the purpose of the migration is to use high-density devices only to benefit from the larger sizes of embedded memories. in this case, you can still use fwlib v1.0. you only need to update the development toolchain-specific files (linker, flash loader, etc.) the purpose of the migration is to use the additional peripherals introduced in high- density devices. in this case, you have to migrate to fwlib v2.0. the development toolchain-specific files also need updating (linker, flash loader, etc.).
fwlib v1.0 to v2.0 migration steps AN2776 6/20 2 fwlib v1.0 to v2.0 migration steps this section describes how to migrate an application based on fwlib v1.0 to v2.0. 2.1 migration steps to update your application code to run on fwlib v2.0, you have to follow the steps listed below: 1. update the toolchain startup files a) project files: device connections and flash memory loader. these files are provided with the latest version of your toolchain that supports high-density and medium-density stm32f10xxx devices. for more information please refer to your toolchain documentation. b) linker configuration and vector table location files. these files are included in the fwlib v2.0 install package under the following directory: stm32f10xfwlib\fwlib\project 2. add fwlib v2.0 source files to the application sources a) replace the stm32f10x_conf.h file of your applicatio n with the latest version provided in fwlib v2.0. b) the stm32f10x_it.c / stm32f10x_it.h files that contain the peripheral isrs (interrupt service routine), have been updated to support the new peripherals and the irq channel updates of existing peripherals. you have to replace the existing stm32f10x_it.h file in your application with the new version provided in fwlib v2.0 and, copy your code from the existing stm32f10x_it.c file to the new one. c) update the part of your application code that uses the tim, spi, dma, usart and nvic drivers. further details are provided in the next section. 2.2 peripheral driver updates this section describes how to port an application code based on the fwlib v1.0 tim, spi, dma, usart and nvic drivers to fwlib v2.0. note: in all examples listed below, source code changes between fwlib v1.0 and v2.0 are indicated in italic and bold. 2.2.1 nvic due to a different number of dma and adc peripherals in medium-density and high density devices, nvic-related code was modified be tween fwlib v1.0 and fwlib v2.0. these changes concern dma and adc interrupts.
AN2776 fwlib v1.0 to v2.0 migration steps 7/20 dmas in medium-density devices there was only one dma controller with seven channels (dma channel1 to dma channel7). in high-density de vices, there is an additional dma controller that supports five channels (dma2 channel1 to dma2 channel5). as a result, the dma already present in medium-density devices was renamed as dma1: dma1 (channel1 to channel7) present in medium-density and high-density devices. dma2 (channel1 to channel5) present only in high-density devices. this change creates the need to update the dma irq channel names that have been modified in stm32f10x_nvic.c / stm32f10x_nvic.h , as detailed in ta b l e 1 below. the example below shows how to configure and enable the dma channel6 irq channel using fwlib v1.0: /* configure and enable dma channel6 irq channel */ nvic_initstructure.nvic_irqchannel = dmachannel6_irqchannel ; nvic_initstructure.nvic_irqchannelpreemptionpriority = 0; nvic_initstructure.nvic_irqchannelsubpriority = 0; nvic_initstructure.nvic_irqchannelcmd = enable; nvic_init(&nvic_initstructure); in fwlib v2.0, you simply need to change ?dmachannel6_irqchannel? by?dma1_channel6_irqchannel? /* configure and enable dma1 channel6 irq channel */ nvic_initstructure.nvic_irqchannel = dma1_channel6_irqchannel ; nvic_initstructure.nvic_irqchannelpreemptionpriority = 0; nvic_initstructure.nvic_irqchannelsubpriority = 0; nvic_initstructure.nvic_irqchannelcmd = enable; nvic_init(&nvic_initstructure); table 1. update of dma irq channel names fwlib v1.0 fwlib v2.0 dmachannel1_irqchannel dma1_channel1_irqchannel dmachannel2_irqchannel dma1_channel2_irqchannel dmachannel3_irqchannel dma1_channel3_irqchannel dmachannel4_irqchannel dma1_channel4_irqchannel dmachannel5_irqchannel dma1_channel5_irqchannel dmachannel6_irqchannel dma1_channel6_irqchannel dmachannel7_irqchannel dma1_channel7_irqchannel
fwlib v1.0 to v2.0 migration steps AN2776 8/20 adcs in the same way, medium-density devices feature two adcs (adc1 and adc2) that share the same irq channel. high-density devices have an additional adc (adc3) with a separate irq channel. for this reason, the adc1 and adc2 irq channel names were modified in stm32f10x_nvic.c / stm32f10x_nvic.h , as detailed in ta b l e 2 below. the example below shows how to configure and enable the adc1 (or adc2) irq channel using fwlib v1.0: /* configure and enable adc1 irq channel */ nvic_initstructure.nvic_irqchannel = adc_irqchannel ; nvic_initstructure.nvic_irqchannelpreemptionpriority = 0; nvic_initstructure.nvic_irqchannelsubpriority = 0; nvic_initstructure.nvic_irqchannelcmd = enable; nvic_init(&nvic_initstructure); in v2.0, you simply need to change ?adc_irqchannel? by ?adc1_2_irqchannel?. /* configure and enable adc1 irq channel */ nvic_initstructure.nvic_irqchannel = adc1_2_irqchannel ; nvic_initstructure.nvic_irqchannelpreemptionpriority = 0; nvic_initstructure.nvic_irqchannelsubpriority = 0; nvic_initstructure.nvic_irqchannelcmd = enable; nvic_init(&nvic_initstructure); note: the corresponding dma and adc isr names have also been modified in stm32f10_it.c /. stm32f10_it.h . 2.2.2 tim in fwlib v1.0 the timer peripherals are covered by two drivers: stm32f10x_tim.c / stm32f10x_tim.h : they cover the functionality of general- purpose timers (tim2, tim3 and tim4). the function format in this driver is as follows: tim_functionname(timx, param1, param2,...) e.g.: tim_itconfig(tim_typedef* timx, u16 tim_it, functionalstate newstate) stm32f10x_tim1.c / stm32f10x_tim1.h : they cover the functionality of the advanced-control timer (tim1). this driver provides the same set of functions as stm32f10x_tim.c / stm32f10x_tim.h plus dedicated functions to cover addtional tim1 features (pwmi mode, complementary pwm with dead-time insertion, etc.). the function format in this driver is as follows: tim1_functionname(param1, param2,...) e.g.: tim1_itconfig(u16 tim1_it, functionalstate newstate) in fwlib v2.0, these two drivers have been merged into a single driver, stm32f10x_tim.c / stm32f10x_tim.h , that covers all the timers available in high- density and medium-density devices: general-purpose timers (tim2, tim3, tim4 and tim5), advanced-control timers (tim1 and tim8) and basic timers (tim6&7). this change affects only application code based on the stm32f10x_tim1.c / stm32f10x_tim1.h driver. the set of functions for tim1 are the table 2. adc1 and adc2 irq channel name update fwlib v1.0 fwlib v2.0 adc_irqchannel adc1_2_irqchannel
AN2776 fwlib v1.0 to v2.0 migration steps 9/20 same but the name is different. in the function name, ?tim1? was changed to ?tim? and a new parameter was added to specify the timer to be configured. e.g.: in fwlib v1.0 the function used to configure the tim1 interrupt is: tim1 _itconfig(tim_it_break, enable) in fwlib v2.0 the function is: tim _itconfig( tim1 , tim_it_break, enable) some typical examples of the tim1 configuration migration from fwlib v1.0 to v2.0 are given below. for the complete list of changes made in the timer driver, please refer to appendix a . time-base configuration typical code for tim1 time-base configuration based on fwlib v1.0: tim 1 _timebasestructure.tim 1 _prescaler = 0; tim 1 _timebasestructure.tim 1 _countermode = tim 1 _countermode_up; tim 1 _timebasestructure.tim 1 _period = 4095; tim 1 _timebasestructure.tim 1 _clockdivision = 0; tim 1 _timebasestructure.tim 1 _repetitioncounter = 0; tim1_timebaseinit (&tim 1 _timebasestructure); using fwlib v2.0, the function name has to be updated and tim1 should be passed as the first parameter value: tim_timebasestructure.tim_prescaler = 0; tim_timebasestructure.tim_countermode = tim_countermode_up; tim_timebasestructure.tim_period = 4095; tim_timebasestructure.tim_clockdivision = 0; tim_timebasestructure.tim_repetitioncounter = 0; tim_timebaseinit ( tim1 , &tim_timebasestructure); tim1 output compare mode configuration typical code for tim1 output compare mode configuration based on fwlib v1.0: tim 1 _ocinitstructure.tim 1 _ocmode = tim 1 _ocmode_timing; tim 1 _ocinitstructure.tim 1 _outputstate = tim 1 _outputstate_enable; tim 1 _ocinitstructure.tim 1 _outputnstate = tim 1 _outputnstate_enable; tim 1 _ocinitstructure.tim 1 _pulse = 2047; tim 1 _ocinitstructure.tim 1 _ocpolarity = tim 1 _ocpolarity_high; tim 1 _ocinitstructure.tim 1 _ocnpolarity = tim 1 _ocnpolarity_high; tim 1 _ocinitstructure.tim 1 _ocidlestate = tim 1 _ocidlestate_set; tim 1 _ocinitstructure.tim 1 _ocnidlestate = tim 1 _ocidlestate_set; tim1_oc1init (&tim 1 _ocinitstructure); tim 1 _ocinitstructure.tim 1 _pulse = 1023; tim1_oc2init (&tim 1 _ocinitstructure); tim 1 _ocinitstructure.tim 1 _pulse = 511; tim1_oc3init (&tim 1 _ocinitstructure); using fwlib v2.0, the function names have to be updated and tim1 should be passed as the first parameter value: tim_ocinitstructure.tim_ocmode = tim_ocmode_timing; tim_ocinitstructure.tim_outputstate = tim_outputstate_enable; tim_ocinitstructure.tim_outputnstate = tim_outputnstate_enable; tim_ocinitstructure.tim_pulse = 2047; tim_ocinitstructure.tim_ocpolarity = tim_ocpolarity_high; tim_ocinitstructure.tim_ocnpolarity = tim_ocnpolarity_high; tim_ocinitstructure.tim_ocidlestate = tim_ocidlestate_set; tim_ocinitstructure.tim_ocnidlestate = tim_ocidlestate_set; tim_oc1init ( tim1 , &tim_ocinitstructure); tim_ocinitstructure.tim_pulse = 1023; tim_oc2init ( tim1 , &tim_ocinitstructure);
fwlib v1.0 to v2.0 migration steps AN2776 10/20 tim_ocinitstructure.tim_pulse = 511; tim_oc3init ( tim1 , &tim_ocinitstructure); timx output compare mode configuration typical code for timx output compare mode configuration based on fwlib v1.0: tim_ocinitstructure.tim_ocmode = tim_ocmode_toggle; tim_ocinitstructure. tim_channel = tim_channel_1 ; tim_ocinitstructure.tim_pulse = 2047; tim_ocinitstructure.tim_ocpolarity = tim_ocpolarity_low; tim_ocinit(tim2, &tim_ocinitstructure); tim_ocinitstructure. tim_channel = tim_channel_2 ; tim_ocinitstructure.tim_pulse = 1023; tim_ocinit(tim2, &tim_ocinitstructure); tim_ocinitstructure. tim_channel = tim_channel_3 ; tim_ocinitstructure.tim_pulse = 511; tim_ocinit(tim2, &tim_ocinitstructure); tim_ocinitstructure. tim_channel = tim_channel_4 ; tim_ocinitstructure.tim_pulse = 255; tim_ocinit(tim2, &tim_ocinitstructure); using fwlib v2.0, the function names have to be updated and the tim_channel parameter is replaced by a new stucture member: tim_outputstate : tim_ocinitstructure.tim_ocmode = tim_ocmode_toggle; tim_ocinitstructure. tim_outputstate = tim_outputstate_enable ; tim_ocinitstructure.tim_pulse = 2047; tim_ocinitstructure.tim_ocpolarity = tim_ocpolarity_low; tim_oc1init(tim2, &tim_ocinitstructure); tim_ocinitstructure. tim_outputstate = tim_outputstate_enable ; tim_ocinitstructure.tim_pulse = 1023; tim_oc2init(tim2, &tim_ocinitstructure); tim_ocinitstructure. tim_outputstate = tim_outputstate_enable ; tim_ocinitstructure.tim_pulse = 511; tim_oc3init(tim2, &tim_ocinitstructure); tim_ocinitstructure. tim_outputstate = tim_outputstate_enable ; tim_ocinitstructure.tim_pulse = 255; tim_oc4init(tim2, &tim_ocinitstructure); counter enable and pwm output control typical code for tim1 counter enable and pwm output control configuration based on fwlib v1.0: /* tim1 counter enable */ tim1_cmd (enable); /* main output enable */ tim1_ctrlpwmoutputs (enable); using fwlib v2.0, the function names have to be updated and tim1 should be passed as the first parameter value: /* tim1 counter enable */ tim_cmd ( tim1 , enable); /* main output enable */ tim_ctrlpwmoutputs ( tim1 , enable); input capture configuration typical code for tim input capture configuration based on fwlib v1.0: t im_icinitstruc ture.tim_icmode = tim_icmode_icap; tim_icinitstructure.tim_channel = tim_channel_1; tim_icinitstructure.tim_icpolarity = tim_icpolarity_rising;
AN2776 fwlib v1.0 to v2.0 migration steps 11/20 tim_icinitstructure.tim_icselection = tim_icselection_directti; tim_icinitstructure.tim_icprescaler = tim_icpsc_div1; tim_icinitstructure.tim_icfilter = 0x0; tim_icinit(tim3, &tim_icinitstructure); tim_selectinputtrigger(tim3, tim_ts_ti1fp1); tim_selectslavemode(tim3, tim_slavemode_reset); /* tim enable counter */ tim_cmd(tim3, enable); in fwlib v2.0, the tim_icmode member of the tim_icinittypedef structure was removed: tim_icinitstructure.tim_channel = tim_channel_1; tim_icinitstructure.tim_icpolarity = tim_icpolarity_rising; tim_icinitstructure.tim_icselection = tim_icselection_directti; tim_icinitstructure.tim_icprescaler = tim_icpsc_div1; tim_icinitstructure.tim_icfilter = 0x0; tim_icinit(tim3, &tim_icinitstructure); tim_selectinputtrigger(tim3, tim_ts_ti1fp1); tim_selectslavemode(tim3, tim_slavemode_reset); /* tim enable counter */ tim_cmd(tim3, enable); pwm input capture configuration typical code for tim pwm input capture configuration based on fwlib v1.0: tim_icinitstructure.tim_icmode = tim_icmode_pwmi; tim_icinitstructure.tim_channel = tim_channel_1; tim_icinitstructure.tim_icpolarity = tim_icpolarity_rising; tim_icinitstructure.tim_icselection = tim_icselection_directti; tim_icinitstructure.tim_icprescaler = tim_icpsc_div1; tim_icinitstructure.tim_icfilter = 0x0; tim_icinit(tim2, &tim_icinitstructure); tim_selectinputtrigger(tim2, tim_ts_ti1fp1); tim_selectslavemode(tim2, tim_slavemode_reset); in fwlib v2.0, the tim_icmode member of the tim_icinittypedef structure was removed and a new function, tim_pwmiconfig , was added: tim_icinitstructure.tim_channel = tim_channel_1; tim_icinitstructure.tim_icpolarity = tim_icpolarity_rising; tim_icinitstructure.tim_icselection = tim_icselection_directti; tim_icinitstructure.tim_icprescaler = tim_icpsc_div1; tim_icinitstructure.tim_icfilter = 0x0; tim_pwmiconfig(tim2, &tim_icinitstructure); tim_selectinputtrigger(tim2, tim_ts_ti1fp1); tim_selectslavemode(tim2, tim_slavemode_reset); 2.2.3 spi in fwlib v1.0, the stm32f10x_spi.c / stm32f10x_spi.h driver is used to cover the functionality of the spi1 and spi2 peripherals. the function format in this driver is as follows: spi_functionname(spix, param1, param2,...) e.g.: spi_itconfig(spi_typedef* spix, u8 spi_it, functionalstate newstate) in fwlib v2.0, this driver was updated to support the new spi3 peripheral and the i 2 s protocol. in high-density devices, the spi2 and spi3 interf aces give the flexibility to use either the spi protocol or the i 2 s audio protocol. these two protocols share some configuration bits plus a dedicated bit for each protocol. the following sections describes the update made on this driver.
fwlib v1.0 to v2.0 migration steps AN2776 12/20 common functions and configuration parameters for spi and i 2 s some spi driver functions were updated to support the i 2 s protocol: 1. ? i2s ? was added in the function name to indicate that it can be used for spi and i 2 s 2. ? i2s ? was added in the configuration parameter to indicate that it can be used for spi and i 2 s 3. the function format is updated as follows: spi_ i2s _ functionname(spix, param1, param2,...) e.g.: spi_ i2s _ itconfig(spi_typedef* spix, u8 spi_ i2s _ it, functionalstate newstate) ta bl e 3 provides the list of the impacted functions. if you are using any function listed in the first column of ta b l e 3 , update the prototypes and parameter name to the new names given in the second column of the table. example: typical code for spi interrupt and dma configuration based on fwlib v1.0: spi_itconfig (spi2, spi_it_txe , enable) spi_dmacmd (spi2, spi_dmareq_rx , enable) using fwlib v2.0, this code becomes: spi_i2s_itconfig (spi2, spi_i2s_it_txe , enable) spi_i2s_dmacmd (spi2, spi_i2s_dmareq_rx , enable) note: in addition to these functions, a new structure is added to this driver to configure only the i 2 s peripheral. spi-specific functions the functions not listed in ta b l e 3 where not modified and are specific to the spi protocol. new functions for i 2 s three functions were added to cover i 2 s protocol-specific configuration: 1. i2s_init(spi_typedef* spix, i2s_inittypedef* i2s_initstruct) 2. i2s_structinit(i2s_inittypedef* i2s_initstruct) 3. i2s_cmd(spi_typedef* spix, functionalstate newstate) table 3. common functions for spi and i 2 s (1) fwlib v1.0 fwlib v2.0 spi_deinit (spi_typedef* spix) spi_i2s_deinit (spi_typedef* spix) spi_itconfig (spi_typedef* spix, u8 spi_it , functionalstate newstate) spi_i2s_itconfig (spi_typedef* spix, u8 spi_i2s_it , functionalstate newstate) spi_dmacmd (spi_typedef* spix, u16 spi_dmareq , functionalstate newstate) spi_i2s_dmacmd (spi_typedef* spix, u16 spi_i2s_dmareq , functionalstate newstate) spi_senddata (spi_typedef* spix, u16 data) spi_i2s_senddata (spi_typedef* spix, u16 data) spi_receivedata (spi_typedef* spix) spi_i2s_receivedata (spi_typedef* spix) spi_getflagstatus (spi_typedef* spix, u16 spi_flag ) spi_i2s_getflagstatus (spi_typedef* spix, u16 spi_i2s_flag ) spi_clearflag (spi_typedef* spix, u16 spi_flag ) spi_i2s_clearflag (spi_typedef* spix, u16 spi_i2s_flag ) spi_getitstatus (spi_typedef* spix, u8 spi_it ) spi_i2s_getitstatus (spi_typedef* spix, u8 spi_i2s_it ) spi_clearitpendingbit (spi_typedef* spix, u8 spi_it ) spi_i2s_clearitpendingbit (spi_typedef* spix, u8 spi_i2s_it ) 1. some parameters are specific fo r spi (e.g.: spi_flag_crcerr) or i 2 s (e.g.: i2s_flag_chside).
AN2776 fwlib v1.0 to v2.0 migration steps 13/20 2.2.4 dma in fwlib v1.0, the stm32f10x_dma.c / stm32f10x_dma.h driver is used to cover the functionality of the dma controller and its seven channels. the function format in this driver is as follows: dma_functionname(dma_channelx, param1, param2,...) e.g.: dma_itconfig(dma_channel_typedef* dma_channelx, u32 dma_it, functionalstate newstate) in fwlib v2.0, this driver was updated to support the new dma2 controller and the five associated channels present in high-density devices. the function names are unchanged compared to fwlib v1.0, only the passed parameter has been updated to cover the dma1 (dma in medium-density devices) and dma2 controllers. this gives the following function format: dma_functionname(dma y _channelx, param1, param2,...) e.g.: dma_itconfig(dma_channel_typedef* dma y _channelx, u32 dma_it, functionalstate newstate) as a result, in code based on fwlib v1.0, only the dma_channel_typedef parameter name needs updating. example: typical code for dma enable and interrupt configuration based on fwlib v1.0: dma_cmd(dma_channel5, enable) dma_itconfig(dma_channel6, dma_it_tc, enable) using fwlib v2.0, this code is: dma_cmd(dma 1 _channel5, enable) dma_itconfig(dma 1 _channel6, dma_it_tc, enable) example: typical code to check whether dma channel6 flag is set, based on fwlib v1.0: /* test if dma channel6 transfer complete flag is set or not */ flagstatus status; status = dma_getflagstatus( dma_flag_tc6 ); using fwlib v2.0, this code is: /* test if dma1 channel6 transfer complete flag is set or not */ flagstatus status; status = dma_getflagstatus( dma1_flag_tc6 ); 2.2.5 usart in fwlib v1.0, the stm32f10x_usart.c / stm32f10x_usart.h driver is used to cover the functionality of the usart1, usart2 and usart3 peripherals. in this driver, the usart is configured through the usart_init function, which takes the usart_inittypedef structure as a parameter. it is the structure that contains the configuration information: usart_init(usart_typedef* usartx, usart_inittypedef* usart_initstruct) the usart_inittypedef structure is defined as shown below: typedef struct { u32 usart_baudrate; u16 usart_wordlength; u16 usart_stopbits; u16 usart_parity; u16 usart_hardwareflowcontrol; u16 usart_mode; u16 usart_clock; u16 usart_cpol; u16 usart_cpha; u16 usart_lastbit;
fwlib v1.0 to v2.0 migration steps AN2776 14/20 } usart_inittypedef; in fwlib v2.0, this driver was updated to support the new uart4 and uart5 peripherals present in high-density devices. uart4 and uart5 do not support synchronous operations like smartcard mode and spi-like communication. usart_init was split up into two functions: usart_init it is used for basic and asynchronous parameter configuration of usart1, usart2, usart3, uart4 and uart5: usart_init(usart_typedef* usartx, usart_inittypedef* usart_initstruct) the usart_inittypedef structure definition is modified as follows: typedef struct { u32 usart_baudrate; u16 usart_wordlength; u16 usart_stopbits; u16 usart_parity; u16 usart_mode; u16 usart_hardwareflowcontrol; } usart_inittypedef; as a result, in code based on fwlib v1.0, if the application does not use the synchronous parameters, update the code as given in the following example: usart configuration based on fwlib v1.0: usart_initstructure.usart_baudrate = 115200; usart_initstructure.usart_wordlength = usart_wordlength_8b; usart_initstructure.usart_stopbits = usart_stopbits_1; usart_initstructure.usart_parity = usart_parity_no ; usart_initstructure.usart_hardwareflowcontrol = usart_hardwareflowcontrol_none; usart_initstructure.usart_mode = usart_mode_rx | usart_mode_tx; usart_initstructure.usart_clock = usart_clock_disable; usart_initstructure.usart_cpol = usart_cpol_low; usart_initstructure.usart_cpha = usart_cpha_2edge; usart_initstructure.usart_lastbit = usart_lastbit_disable; /* configure usart1 */ usart_init(usart1, &usart_initstructure); in fwlib v2.0, the usart_clock, usart_ cpol, usart_cpha and usart_lastbit structure members were removed: usart_initstructure.usart_baudrate = 115200; usart_initstructure.usart_wordlength = usart_wordlength_8b; usart_initstructure.usart_stopbits = usart_stopbits_1; usart_initstructure.usart_parity = usart_parity_no ; usart_initstructure.usart_hardwareflowcontrol = usart_hardwareflowcontrol_none; usart_initstructure.usart_mode = usart_mode_rx | usart_mode_tx; /* configure usart1 basic and asynchronous paramters */ usart_init(usart1, &usart_initstructure);
AN2776 fwlib v1.0 to v2.0 migration steps 15/20 usart_clockinit it is used for the synchronous parameter configuration of usart1, usart2, and usart3: usart_clockinit(usart_typedef* usartx,usart_clockinittypedef*usart_clockinitstruct) the usart_clockinittypedef structure is defined as shown below: typedef struct { u16 usart_clock; u16 usart_cpol; u16 usart_cpha; u16 usart_lastbit; } usart_clockinittypedef; as a result, in code based on fwlib v1.0, if the application uses the synchronous parameters, update the code as shown in the following example: usart configuration based on fwlib v1.0: usart_initstructure.usart_baudrate = 115200; usart_initstructure.usart_wordlength = usart_wordlength_8b; usart_initstructure.usart_stopbits = usart_stopbits_1; usart_initstructure.usart_parity = usart_parity_no ; usart_initstructure.usart_hardwareflowcontrol = usart_hardwareflowcontrol_none; usart_initstructure.usart_mode = usart_mode_rx | usart_mode_tx; usart_initstructure.usart_clock = usart_clock_enable; usart_initstructure.usart_cpol = usart_cpol_high; usart_initstructure.usart_cpha = usart_cpha_2edge; usart_initstructure.usart_lastbit = usart_lastbit_enable; usart_init(usart1, &usart_initstructure); /* configure the usart1 */ usart_init(usart1, &usart_initstructure); in fwlib v2.0, this configuration is done through two functions: usart_clockinitstructure.usart_clock = usart_clock_enable; usart_clockinitstructure.usart_cpol = usart_cpol_high; usart_clockinitstructure.usart_cpha = usart_cpha_2edge; usart_clockinitstructure.usart_lastbit = usart_lastbit_enable; /* configure the usart1 synchronous paramters */ usart_clockinit (usart1, &usart_clockinitstructure); usart_initstructure.usart_baudrate = 115200; usart_initstructure.usart_wordlength = usart_wordlength_8b; usart_initstructure.usart_stopbits = usart_stopbits_1; usart_initstructure.usart_parity = usart_parity_no ; usart_initstructure.usart_hardwareflowcontrol = usart_hardwareflowcontrol_none; usart_initstructure.usart_mode = usart_mode_rx | usart_mode_tx; /* configure usart1 basic and asynchronous paramters */ usart_init (usart1, &usart_initstructure);
timer driver changes AN2776 16/20 appendix a timer driver changes ta bl e 4 gives the list of the changes made in the timer driver. table 4. changes made in the timer driver stm32 fwlib v1.0 stm32f10x_tim1.c, .h functions stm32 fwlib v1.0 stm32f10x_tim.c, .h functions stm32 fwlib v2.0 stm32f10x_tim.c, .h functions void tim1_deinit(void) void tim_deinit() void tim_deinit() void tim1_timebaseinit() void tim_ti mebaseinit() void tim_timebaseinit() void tim1_oc1init() void tim_ocinit() void tim_oc1init() (1) void tim1_oc2init() void tim_oc2init() (1) void tim1_oc3init() void tim_oc3init() (1) void tim1_oc4init() void tim_oc4init() (1) void tim1_icinit() void tim_icinit() void tim_icinit() void tim1_pwmiconfig() void tim_pwmiconfig() (1) void tim1_timebasestructinit() void tim_timeba sestructinit() void ti m_timebasestructinit() void tim1_ocstructinit() void tim_ocstructinit() void tim_ocstructinit() void tim1_icstructinit() void tim_icstructinit() void tim_icstructinit() void tim1_bdtrstructinit() void tim_bdtrstructinit() (2) void tim1_cmd() void tim_cmd() void tim_cmd() void tim1_ctrlpwmoutputs() void tim_ctrlpwmoutputs() (2) void tim1_itconfig() void tim_ itconfig() void tim_itconfig() void tim1_dmaconfig() void tim_ dmaconfig() void tim_dmaconfig() void tim1_dmacmd() void tim_dmacmd() void tim_dmacmd() void tim1_internalclockconfig(void) void tim_inter nalclockconfig() void tim_internalclockconfig(void) void tim1_etrclockmode1config() void tim_etrclo ckmode1config() void tim_etrclockmode1config() void tim1_etrclockmode2config() void tim_etrclockmode2config() void tim_etrclockmode2config() void tim1_etrconfig() void tim_etrconfig() void tim_etrconfig() void tim1_itrxexternalclockconfig() vo id tim_itrxexternalclockconfig(); void tim_itrxexternalclockconfig() void tim1_tixexternalclockconfig() void tim_tixext ernalclockconfig() void tim_tixexternalclockconfig() void tim1_selectinputtrigger() void tim_sele ctinputtrigger() void tim_selectinputtrigger() void tim1_updatedisableconfig() void tim_updat edisableconfig() void tim_updatedisableconfig() void tim1_updaterequestconfig() void tim_updat erequestconfig() void tim_updaterequestconfig() void tim1_selecthallsensor() void tim_selecthallsensor(); vo id tim_selecthallsensor() void tim1_selectonepulsemode() void tim_select onepulsemode(); void tim_selectonepulsemode() void tim1_selectoutputtrigger() void tim_sele ctoutputtrigger(); void tim_selectoutputtrigger() void tim1_selectslavemode() void tim_sele ctslavemode(); void tim_selectslavemode()
AN2776 timer driver changes 17/20 void tim1_selectmasterslavemode() void tim_selectmasterslavemode() v oid tim_selectmasterslavemode() void tim1_encoderinterfaceconfig() void tim_encoder interfaceconfig() void tim_encoderinterfaceconfig() void tim1_prescalerconfig() void tim_prescalerconfig() void tim_prescalerconfig() void tim1_countermodeconfig() void tim_count ermodeconfig() void tim_countermodeconfig() void tim1_forcedoc1config() void tim_fo rcedoc1config() void tim_forcedoc1config() void tim1_forcedoc2config() void tim_fo rcedoc2config() void tim_forcedoc2config() void tim1_forcedoc3config() void tim_fo rcedoc3config() void tim_forcedoc3config() void tim1_forcedoc4config() void tim_fo rcedoc4config() void tim_forcedoc4config() void tim1_arrpreloadconfig() void tim_arrp reloadconfig() void tim_arrpreloadconfig() void tim1_selectcom() void tim_selectcom() void tim1_selectccdma() void tim_ selectccdma() void tim_selectccdma() void tim1_ccpreloadcontrol() void tim_ccpreloadcontrol() void tim1_oc1preloadconfig() void tim_oc1p reloadconfig() void tim_oc1preloadconfig() void tim1_oc2preloadconfig() void tim_oc2p reloadconfig() void tim_oc2preloadconfig() void tim1_oc3preloadconfig() void tim_oc3p reloadconfig() void tim_oc3preloadconfig() void tim1_oc4preloadconfig() void tim_oc4p reloadconfig() void tim_oc4preloadconfig() void tim1_oc1fastconfig() void tim_oc 1fastconfig() void tim_oc1fastconfig() void tim1_oc2fastconfig() void tim_oc 2fastconfig() void tim_oc2fastconfig() void tim1_oc3fastconfig() void tim_oc 3fastconfig() void tim_oc3fastconfig() void tim1_oc4fastconfig() void tim_oc 4fastconfig() void tim_oc4fastconfig() void tim1_clearoc1ref() void tim_clearoc1ref() void tim_clearoc1ref() void tim1_clearoc2ref() void tim_clearoc2ref() void tim_clearoc2ref() void tim1_clearoc3ref() void tim_clearoc3ref() void tim_clearoc3ref() void tim1_clearoc4ref() void tim_clearoc4ref() void tim_clearoc4ref() void tim1_generateevent() void tim_generateevent(); void tim_generateevent() void tim1_oc1polarityconfig() void tim_oc1p olarityconfig() void tim_oc1polarityconfig() void tim1_oc1npolarityconfig() void tim_oc1npolarityconfig() void tim1_oc2polarityconfig() void tim_oc2p olarityconfig() void tim_oc2polarityconfig() void tim1_oc2npolarityconfig() void tim_oc2npolarityconfig() void tim1_oc3polarityconfig() void tim_oc3p olarityconfig() void tim_oc3polarityconfig() void tim1_oc3npolarityconfig() void tim_oc3npolarityconfig() void tim1_oc4polarityconfig() void tim_oc4p olarityconfig() void tim_oc4polarityconfig() void tim1_ccxcmd() void tim_ccxcmd() void tim1_ccxncmd() void tim_ccxncmd() table 4. changes made in the timer driver (continued) stm32 fwlib v1.0 stm32f10x_tim1.c, .h functions stm32 fwlib v1.0 stm32f10x_tim.c, .h functions stm32 fwlib v2.0 stm32f10x_tim.c, .h functions
timer driver changes AN2776 18/20 void tim1_selectocxm() void tim_selectocxm() void tim1_setcounter() void tim_setcounter() void tim_setcounter() void tim1_setautoreload() void tim_se tautoreload() void tim_setautoreload() void tim1_setcompare1() void tim_se tcompare1() void tim_setcompare1() void tim1_setcompare2() void tim_se tcompare2() void tim_setcompare2() void tim1_setcompare3() void tim_se tcompare3() void tim_setcompare3() void tim1_setcompare4() void tim_se tcompare4() void tim_setcompare4() void tim1_setic1prescaler() void tim_setic1prescaler() vo id tim_setic1prescaler() void tim1_setic2prescaler() void tim_setic2prescaler() vo id tim_setic2prescaler() void tim1_setic3prescaler() void tim_setic3prescaler() vo id tim_setic3prescaler() void tim1_setic4prescaler() void tim_setic4prescaler() vo id tim_setic4prescaler() void tim1_setclockdivision() void tim_setc lockdivision() void tim_setclockdivision() u16 tim1_getcapture1(void)s u16 tim_ge tcapture1() u16 tim_getcapture1(void) u16 tim1_getcapture2(void) u16 tim_ge tcapture2() u16 tim_getcapture2(void) u16 tim1_getcapture3(void) u16 tim_ge tcapture3() u16 tim_getcapture3(void) u16 tim1_getcapture4(void) u16 tim_ge tcapture4() u16 tim_getcapture4(void) u16 tim1_getcounter(void) u16 tim_ge tcounter() u16 tim_getcounter(void) u16 tim1_getprescaler(void) u16 tim_getp rescaler() u16 tim_getprescaler(void) flagstatus tim1_get flagstatus() flagstatus tim_getflagsta tus() flagstatus tim_getflagstatus() void tim1_clearflag() void tim_clearflag() void tim_clearflag() itstatus tim1_getit status() itstatus tim_getitstatus() itstatus tim_getitstatus() void tim1_clearitpendingbit() void tim_clear itpendingbit() void tim_clearitpendingbit() 1. added for timx. 2. available for tim1 and tim8. table 4. changes made in the timer driver (continued) stm32 fwlib v1.0 stm32f10x_tim1.c, .h functions stm32 fwlib v1.0 stm32f10x_tim.c, .h functions stm32 fwlib v2.0 stm32f10x_tim.c, .h functions
AN2776 revision history 19/20 revision history table 5. document revision history date revision changes 29-may-2008 1 initial release.
AN2776 20/20 please read carefully: information in this document is provided solely in connection with st products. stmicroelectronics nv and its subsidiaries (?st ?) reserve the right to make changes, corrections, modifications or improvements, to this document, and the products and services described he rein at any time, without notice. all st products are sold pursuant to st?s terms and conditions of sale. purchasers are solely responsible for the choice, selection and use of the st products and services described herein, and st as sumes no liability whatsoever relating to the choice, selection or use of the st products and services described herein. no license, express or implied, by estoppel or otherwise, to any intellectual property rights is granted under this document. i f any part of this document refers to any third party products or services it shall not be deemed a license grant by st for the use of such third party products or services, or any intellectual property contained therein or considered as a warranty covering the use in any manner whatsoev er of such third party products or services or any intellectual property contained therein. unless otherwise set forth in st?s terms and conditions of sale st disclaims any express or implied warranty with respect to the use and/or sale of st products including without limitation implied warranties of merchantability, fitness for a parti cular purpose (and their equivalents under the laws of any jurisdiction), or infringement of any patent, copyright or other intellectual property right. unless expressly approved in writing by an authorized st representative, st products are not recommended, authorized or warranted for use in milita ry, air craft, space, life saving, or life sustaining applications, nor in products or systems where failure or malfunction may result in personal injury, death, or severe property or environmental damage. st products which are not specified as "automotive grade" may only be used in automotive applications at user?s own risk. resale of st products with provisions different from the statements and/or technical features set forth in this document shall immediately void any warranty granted by st for the st product or service described herein and shall not create or extend in any manner whatsoev er, any liability of st. st and the st logo are trademarks or registered trademarks of st in various countries. information in this document supersedes and replaces all information previously supplied. the st logo is a registered trademark of stmicroelectronics. all other names are the property of their respective owners. ? 2008 stmicroelectronics - all rights reserved stmicroelectronics group of companies australia - belgium - brazil - canada - china - czech republic - finland - france - germany - hong kong - india - israel - ital y - japan - malaysia - malta - morocco - singapore - spain - sweden - switzerland - united kingdom - united states of america www.st.com


▲Up To Search▲   

 
Price & Availability of AN2776

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X